package com.yf.tz.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import com.yf.tz.entity.MallAddressEntity;
import com.yf.tz.service.MallAddressService;
import com.yf.response.R;


/**
 * 商城地址Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Mon Jul 20 09:44:30 CST 2020
 */
@RestController
@RequestMapping("/mall/address")
public class MallAddressController {
    @Autowired
    private MallAddressService mallAddressService;

    /**
     * 列表商城地址
     */
    @SysLog("查看商城地址")
    @RequestMapping("/list")
    @RequiresPermissions("mall:address:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<MallAddressEntity> mallAddressList = mallAddressService.queryList(params);
        return R.ok(new PageInfo(mallAddressList));
    }

    /**
     * 查看商城地址
     */
    @SysLog("查看商城地址")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("mall:address:info")
    public R info(@PathVariable("id") Long id) {
        MallAddressEntity mallAddress = mallAddressService.get(id);

        return R.ok(mallAddress);
    }

    /**
     * 保存商城地址
     */
    @SysLog("保存商城地址")
    @RequestMapping("/save")
    @RequiresPermissions("mall:address:save")
    public R save(MallAddressEntity mallAddress) {
        mallAddressService.save(mallAddress);

        return R.ok(mallAddress);
    }

    /**
     * 修改商城地址
     */
    @SysLog("修改商城地址")
    @RequestMapping("/update")
    @RequiresPermissions("mall:address:update")
    public R update(MallAddressEntity mallAddress) {
        mallAddressService.update(mallAddress);

        return R.ok(mallAddress);
    }

    /**
     * 删除商城地址
     */
    @SysLog("删除商城地址")
    @RequestMapping("/delete")
    @RequiresPermissions("mall:address:delete")
    public R delete(Long[]ids) {
        mallAddressService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有商城地址
     */
    @SysLog("所有商城地址")
    @RequestMapping("/all")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<MallAddressEntity> mallAddressList = mallAddressService.queryList(params);

        return R.ok(mallAddressList);
    }

    /***********自定义开始***********/
}
